package com.hjxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hjxy.dao.CollegeDao;
import com.hjxy.dao.StudentDao;
import com.hjxy.pojo.Student;
import com.hjxy.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: ty
 * @createDate: 2020/9/28
 * @version: 1.0
 */
@Service
public class StudentServiceImpl implements StudentService {
    private StudentDao studentDao;
    private CollegeDao collegeDao;

    @Autowired
    //private StudentDao studentDao;
    public StudentServiceImpl(StudentDao studentDao, CollegeDao collegeDao){
        this.studentDao = studentDao;
        this.collegeDao = collegeDao;
    }

    @Override
    public List<Student> queryAllStudent() {
        List<Student> students = studentDao.queryAllStudent();
        System.out.println(studentDao.queryAllStudent()+"<=======studentDao.queryAllStudent()");
        return students;
    }

    @Override
    public int AddStudent(Student student) {
        int t = studentDao.addStudent(student);
        return t;
    }

    @Override
    public int deleteStudent(int userId) {
        return studentDao.deleteStudent(userId);
    }

    @Override
    public boolean edit1(Student student) {
        return  studentDao.updateStudent(student)>0;
    }

    @Override
    public boolean edit2(Student student) {
        return studentDao.updateStudent1(student)>0;
    }

//    @Override
//    public int edit1(Student student) {
//
//        int s = studentDao.updateStudent(student);
//        return s;
//    }
//
//    @Override
//    public int edit2(Student student) {
//        return studentDao.updateStudent1(student);
//    }

    @Override
    public Student edit3(Integer userId) {
        return studentDao.CX(userId);
    }


//    @Override
//    public PageInfo<Student> paging(Integer currentPage, Integer pageSize) {
//        PageHelper.startPage(currentPage, pageSize);
//        List<Student> list = studentDao.FY();
//        PageInfo<Student> page = new PageInfo<>(list);
//        return page;
//    }
}
